package org.ala.tiktools.sharddb.mybatis.pager.after_pager;

import org.ala.tiktools.mybatis.pager.Pager;

/**
 * @author ala
 * @date 2025-03-08 18:31
 */
@SuppressWarnings("serial")
public class ShardAfterPager<E> extends Pager<E> {
    /**
     * build分页条件
     * @param no    从1开始
     * @param size
     * @return
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
	public static ShardAfterPager build(int no, int size) {
        ShardAfterPager pager = new ShardAfterPager();
        pager.no = no;
        pager.size = size;
        pager.limit = size;
        pager.offset = Math.max((no - 1) * size, 0);
        return pager;
    }
    /**
     * build分页条件
     * @param no    从1开始
     * @param size
     * @return
     */
    public static <E> ShardAfterPager<E> build(int no, int size, Class<E> clazz) {
        ShardAfterPager<E> pager = new ShardAfterPager<E>();
        pager.no = no;
        pager.size = size;
        pager.limit = size;
        pager.offset = Math.max((no - 1) * size, 0);
        return pager;
    }
}
